/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package upc.edu.alquiler.ws;

import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import upc.edu.alquiler.excepcion.DAOExcepcion;
import upc.edu.alquiler.model.Persona;
import upc.edu.alquiler.service.PersonaService;


    /**
 *
 * @author SONY
 */
@WebService(serviceName = "PersonaWS")
public class AlquilerCanchaWS {

    private PersonaService personaService = new PersonaService();
     /** This is a sample web service operation
     */
    @WebMethod(operationName = "Login")
    public PersonaResponse Login(@WebParam(name = "email") String email,
                                 @WebParam(name = "password") String pwd) throws DAOExcepcion {
    
        
        PersonaResponse personaResponse =  new PersonaResponse();    
        
        Persona pe = new Persona();
        try {
            pe = personaService.consultarPersona(email);
        } catch (SQLException ex) {
            Logger.getLogger(AlquilerCanchaWS.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        if(pe.getNombres().isEmpty()){
            personaResponse.setCodigoRetorno(0);
            personaResponse.setCantidadRegistros(0);
            personaResponse.setMensajeRetorno("No se encontraron registros");
        }else{
            personaResponse.setCodigoRetorno(1);
            personaResponse.setCantidadRegistros(1);
            personaResponse.setMensajeRetorno("Se encontraron " + 1 + " registros");
        }
        
        
        return personaResponse;     
     
    
     

}

}
